package bb.lanxing.model.database;

import android.os.Parcel;
import android.os.Parcelable;
//import com.orm.SugarRecord;

import org.litepal.crud.LitePalSupport;

import bb.lanxing.App;
import bb.lanxing.model.json.ServerUser;

public class PostQueue extends LitePalTableBase implements Parcelable {
    public static final Parcelable.Creator<PostQueue> CREATOR = new Parcelable.Creator<PostQueue>() {

        public PostQueue createFromParcel(Parcel source) {
            return new PostQueue(source);
        }

        public PostQueue[] newArray(int size) {
            return new PostQueue[size];
        }
    };
    public static final int MAX_RETRY_COUNT = 2;
    public static final int STATE_NONE = 0;
    public static final int STATE_SENDING = 1;
    public static final int STATE_FAILED = 2;

    public static final int TYPE_TOPIC = 1;
    public static final int TYPE_TOPIC_COMMENT = 2;
    public static final int TYPE_CLUB_NOTICE = 4;
    public static final int TYPE_CLUB_COMMENT = 8;
    public static final int TYPE_WORKOUT_COMMENT = 16;
    public static final int TYPE_LUSHU_COMMENT = 32;
    public static final int TYPE_SHOP_COMMENT = 64;
    private String content;
    private long createTime;
    private String images;
    private int retryTimes;
    private int state;
    private long subId;
    private int type;

    @Override
    public int describeContents() {
        return 0;
    }

    public PostQueue(long subId, int type, String content) {
        this.state = 0;
        this.subId = subId;
        this.type = type;
        this.content = content;
        this.retryTimes = 0;
        this.createTime = System.currentTimeMillis();
    }

    public static ServerUser buildCurrentUser() {
        ServerUser serverUser = new ServerUser();
        User signinUser = App.getContext().getSigninUser();
        serverUser.setUserId(signinUser.getUid());
        serverUser.setName(signinUser.getName());
        serverUser.setPhotoUrl(signinUser.getPhotoUrl());
        serverUser.setPlateNum(signinUser.getPlateNum());
        serverUser.setLevel(signinUser.getLevel());
        serverUser.setMedalSmall(signinUser.getMedalSmall());
        return serverUser;
    }

    public long getSubId() {
        return this.subId;
    }

    public void setSubId(long subId) {
        this.subId = subId;
    }

    public int getType() {
        return this.type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getContent() {
        return this.content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getImages() {
        return this.images;
    }

    public void setImages(String images) {
        this.images = images;
    }

    public int getState() {
        return this.state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public int getRetryTimes() {
        return this.retryTimes;
    }

    public void setRetryTimes(int retryTimes) {
        this.retryTimes = retryTimes;
    }

    public long getCreateTime() {
        return this.createTime;
    }

    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }

    @Override // android.os.Parcelable
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(this.id == null ? -1L : this.id);
        dest.writeLong(this.subId);
        dest.writeInt(this.type);
        dest.writeString(this.content);
        dest.writeString(this.images);
        dest.writeInt(this.state);
        dest.writeInt(this.retryTimes);
        dest.writeLong(this.createTime);
    }

    public PostQueue() {
        this.state = 0;
    }

    protected PostQueue(Parcel in2) {
        this.state = 0;
        this.id = in2.readLong();
        if (this.id < 0) {
            this.id = null;
        }
        this.subId = in2.readLong();
        this.type = in2.readInt();
        this.content = in2.readString();
        this.images = in2.readString();
        this.state = in2.readInt();
        this.retryTimes = in2.readInt();
        this.createTime = in2.readLong();
    }

    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        PostQueue postQueue = (PostQueue) o;
        if (this.id.equals(postQueue.id) && this.subId == postQueue.subId && this.type == postQueue.type) {
            String str = this.content;
            String str2 = postQueue.content;
            return str != null ? str.equals(str2) : str2 == null;
        }
        return false;
    }

    public int hashCode() {
        long j = this.subId;
        int i = ((((int) (j ^ (j >>> 32))) * 31) + this.type) * 31;
        String str = this.content;
        return i + (str != null ? str.hashCode() : 0);
    }
}
